import { createApp } from 'vue';
import MiConfirm from './MiConfirm.vue'

export default function (options: {
    title?: string;
    text?: string;
    textTitle?: string;
    isDefault?: boolean
}) {
    const divEle = document.createElement('div')
    document.body.appendChild(divEle)
    let app: any = null;
    return new Promise((resolve, reject) => {
        app = createApp(MiConfirm, { ...options, resolve, reject });
        app.mount(divEle)
    })
        .then(() => {
            app.unmount()
            document.body.removeChild(divEle)
        })
        .catch(() => {
            app.unmount()
            document.body.removeChild(divEle)
            return Promise.reject()
        })
}